package net.yla.smartbus.module.controller.web.ba.log;

import net.yla.smartbus.core.api.ApiResult;
import net.yla.smartbus.core.base.BaseController;
import net.yla.smartbus.core.constants.UserRoleEnum;
import net.yla.smartbus.module.ba.log.query.UserLogQuery;
import net.yla.smartbus.module.ba.log.serice.UserLogService;
import net.yla.smartbus.module.ba.right.roles.service.RolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:LiuJie
 * @date:2021/6/17
 * @description:查询日志
 */
@RestController
@RequestMapping("/api/web/ba")
public class UserLogController extends BaseController {

    @Autowired
    private UserLogService userLogService;

    @Autowired
    private RolesService rolesService;

    /**
     * 查询日志
     *
     * @param query
     * @return
     */
    @PostMapping("/log/select")
    public ApiResult listByQuery(@RequestBody UserLogQuery query) {
        rolesService.userRoleEvaluation(UserRoleEnum.LOG_SELECT, getToken(), getIpAddress());
        return success(userLogService.listByQuery(query));
    }

}
